package com.demo.coretech.abnormal;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * @Authors：gaoyang
 * @CreateTime：2021/11/29 10:45
 * @Description：异常测试类
 */
public class AbnormalTest {

    public static void main(String[] args) throws FileNotFoundException {
        System.out.println(f(3));
        try (Scanner in = new Scanner(new FileInputStream("/Users/environment/test.txt"),"UTF-8");
             PrintWriter out = new PrintWriter("out.txt"))
        {
            while (in.hasNext()){
                out.println(in.next().toUpperCase());
            }
        }
    }

    public static int f(int n){
        try {
            int r = n*n;
            return r;
        }finally {
            if (n==2) {
                return 0;
            }
        }
    }
}
